package pre.lxm.demo.drawable;


import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import pre.lxm.demo.R;

public class DrawableActivity extends AppCompatActivity {


    @BindView(R.id.tv1)
    TextView tv1;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_drawable);
        ButterKnife.bind(this);
        GradientDrawable gradientDrawable = new ShapeBackground.ShapeBuilder().setStrokeWidth(1).setStrokeColor(Color
                .parseColor("#FF0000")).setShape(GradientDrawable.RECTANGLE).setColor(Color.parseColor("#00FFFF"))
                .build();


        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            tv1.setBackground(gradientDrawable);
        } else {
            tv1.setBackgroundDrawable(gradientDrawable);
        }

    }
}
